package cn.jsj.machine.tool;

import org.springframework.stereotype.Component;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;

@Component
public class HashMapBuilder {
    public HashMap<String,Object> build(int state, String message, Object jsonInformation){
        HashMap<String,Object> storage = new HashMap<>();
        storage.put("state",state);
        storage.put("message",message);
        storage.put("data",jsonInformation);
        return storage;
    }

    public HashMap<String,Object> buildList(List list){
        HashMap<String,Object> storage = new HashMap<>();
        storage.put("rows",list);
        if(list == null){
            storage.put("total",0);
            return storage;
        }
        storage.put("total",list.size());
        return storage;
    }
}
